<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生词本 - 乐考无忧</title>
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/bootstrap-icons.css">
    <style>
        body {
            background-color: #f0f9f9;
            padding-bottom: 60px;
        }
        .header {
            padding: 15px;
            background: white;
            position: sticky;
            top: 0;
            z-index: 1000;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }
        .search-bar {
            background: #f5f5f5;
            border-radius: 20px;
            padding: 8px 15px;
            margin: 10px 15px;
        }
        .word-card {
            background: white;
            border-radius: 15px;
            padding: 20px;
            margin: 15px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.05);
        }
        .word-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
        }
        .word-text {
            font-size: 1.2rem;
            font-weight: bold;
        }
        .phonetic {
            color: #666;
            font-size: 0.9rem;
        }
        .meaning {
            color: #333;
            margin: 10px 0;
        }
        .example {
            background: #f8f9fa;
            padding: 12px;
            border-radius: 8px;
            margin: 10px 0;
            font-size: 0.95rem;
        }
        .word-source {
            color: #666;
            font-size: 0.85rem;
        }
        .word-tags {
            margin-top: 10px;
        }
        .word-tags .badge {
            margin-right: 5px;
            padding: 5px 10px;
        }
        .filter-bar {
            padding: 10px 15px;
            background: white;
            position: sticky;
            top: 56px;
            z-index: 999;
        }
        .stats-card {
            background: linear-gradient(45deg, #00b8a9, #20d6c7);
            color: white;
            border-radius: 15px;
            padding: 15px;
            margin: 15px;
        }
        .floating-btn {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 50px;
            height: 50px;
            border-radius: 25px;
            background: #00b8a9;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        .mastered-btn {
            background-color: white;
            border: 1px solid #198754;
            color: #198754;
        }
        .mastered-btn.mastered {
            background-color: #198754;
            color: white;
        }
        .word-header .btn {
            width: 36px;
            height: 36px;
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        /* 可以添加一些输入框的样式 */
        .form-control-lg {
            font-size: 1.2rem;
            padding: 12px 15px;
            border-radius: 10px;
        }
        
        .form-control-lg:focus {
            border-color: #00b8a9;
            box-shadow: 0 0 0 0.25rem rgba(0, 184, 169, 0.25);
        }
    </style>
</head>
<body>
    <!-- 头部 -->
    <div class="header d-flex align-items-center">
        <a href="index.html" class="text-dark"><i class="bi bi-chevron-left fs-4"></i></a>
        <h5 class="mb-0 mx-auto">生词本</h5>
    </div>

    <!-- 搜索栏 -->
    <div class="search-bar d-flex align-items-center">
        <i class="bi bi-search me-2"></i>
        <input type="text" class="form-control border-0 bg-transparent" placeholder="搜索单词...">
    </div>

    <!-- 统计卡片 -->
    <div class="stats-card">
        <div class="d-flex justify-content-between align-items-center">
            <div>
                <h6 class="mb-1">今日新增</h6>
                <h3 class="mb-0">12个</h3>
            </div>
            <div>
                <h6 class="mb-1">总计单词</h6>
                <h3 class="mb-0">486个</h3>
            </div>
            <div>
                <h6 class="mb-1">已掌握</h6>
                <h3 class="mb-0">324个</h3>
            </div>
        </div>
    </div>

    <!-- 筛选栏 -->
    <div class="filter-bar">
        <div class="d-flex justify-content-between">
            <div class="btn-group">
                <button class="btn btn-outline-secondary active">全部</button>
                <button class="btn btn-outline-secondary">未掌握</button>
                <button class="btn btn-outline-secondary">已掌握</button>
            </div>
            <div class="dropdown">
                <button class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown">
                    来源
                </button>
                <ul class="dropdown-menu">
                    <li><a class="dropdown-item" href="#">阅读文章</a></li>
                    <li><a class="dropdown-item" href="#">完形填空</a></li>
                    <li><a class="dropdown-item" href="#">翻译</a></li>
                </ul>
            </div>
        </div>
    </div>

    <!-- 单词列表 -->
    <div class="word-list">
        <!-- 单词卡片 -->
        <div class="word-card">
            <div class="word-header">
                <div>
                    <div class="word-text">deteriorate</div>
                    <div class="phonetic">/dɪˈtɪərɪəreɪt/</div>
                </div>
                <div class="d-flex gap-2">
                    <button class="btn btn-outline-primary btn-sm">
                        <i class="bi bi-volume-up"></i>
                    </button>
                    <button class="btn btn-outline-success btn-sm mastered-btn" onclick="toggleMastered(this)">
                        <i class="bi bi-check-lg"></i>
                    </button>
                </div>
            </div>
            <div class="meaning">
                v. 恶化，变坏；（使）退化
            </div>
            <div class="example">
                The economic situation continued to deteriorate throughout the year.
                <div class="text-muted mt-1">经济形势在这一年中持续恶化。</div>
            </div>
            <div class="word-source">
                <i class="bi bi-bookmark"></i>
                来自：2022年阅读 Text 3
            </div>
        </div>

        <!-- 更多单词卡片 -->
        <div class="word-card">
            <div class="word-header">
                <div>
                    <div class="word-text">resilient</div>
                    <div class="phonetic">/rɪˈzɪliənt/</div>
                </div>
                <div class="d-flex gap-2">
                    <button class="btn btn-outline-primary btn-sm">
                        <i class="bi bi-volume-up"></i>
                    </button>
                    <button class="btn btn-outline-success btn-sm mastered-btn" onclick="toggleMastered(this)">
                        <i class="bi bi-check-lg"></i>
                    </button>
                </div>
            </div>
            <div class="meaning">
                adj. 有弹性的；能快速恢复的；适应力强的
            </div>
            <div class="example">
                Children are generally more resilient than adults.
                <div class="text-muted mt-1">儿童通常比成年人更有适应力。</div>
            </div>
            <div class="word-source">
                <i class="bi bi-bookmark"></i>
                来自：2023年完形填空
            </div>
        </div>
    </div>

    <!-- 在body末尾添加模态框 -->
    <div class="modal fade" id="addWordModal" tabindex="-1">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加生词</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <form id="addWordForm">
                        <div class="mb-3">
                            <input type="text" 
                                   class="form-control form-control-lg" 
                                   placeholder="输入单词..."
                                   required
                                   autocomplete="off">
                        </div>
                        <div class="text-muted small">
                            <i class="bi bi-info-circle"></i>
                            系统会自动获取单词的释义、音标等信息
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="addNewWord()">添加</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 悬浮添加按钮 -->
    <button class="floating-btn border-0" data-bs-toggle="modal" data-bs-target="#addWordModal">
        <i class="bi bi-plus-lg fs-4"></i>
    </button>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        function toggleMastered(button) {
            // 切换按钮的掌握状态
            button.classList.toggle('mastered');
            
            // 获取单词卡片
            const wordCard = button.closest('.word-card');
            
            if (button.classList.contains('mastered')) {
                // 已掌握状态
                showToast('已标记为掌握！');
            } else {
                // 未掌握状态
                showToast('已取消掌握标记');
            }
        }

        // 添加提示消息功能
        function showToast(message) {
            const toast = document.createElement('div');
            toast.className = 'toast-message';
            toast.textContent = message;
            document.body.appendChild(toast);
            
            // 2秒后自动消失
            setTimeout(() => {
                toast.remove();
            }, 2000);
        }

        function addNewWord() {
            const form = document.getElementById('addWordForm');
            const input = form.querySelector('input');
            const word = input.value.trim();
            
            if (!word) {
                showToast('请输入单词');
                return;
            }

            // 模拟添加单词卡片（实际项目中这里会调用API获取单词信息）
            const wordList = document.querySelector('.word-list');
            const newWordCard = document.createElement('div');
            newWordCard.className = 'word-card';
            
            newWordCard.innerHTML = `
                <div class="word-header">
                    <div>
                        <div class="word-text">${word}</div>
                        <div class="phonetic">获取中...</div>
                    </div>
                    <div class="d-flex gap-2">
                        <button class="btn btn-outline-primary btn-sm">
                            <i class="bi bi-volume-up"></i>
                        </button>
                        <button class="btn btn-outline-success btn-sm mastered-btn" onclick="toggleMastered(this)">
                            <i class="bi bi-check-lg"></i>
                        </button>
                    </div>
                </div>
                <div class="meaning">释义获取中...</div>
                <div class="word-source">
                    <i class="bi bi-bookmark"></i>
                    来自：手动添加
                </div>
            `;

            // 将新卡片添加到列表开头
            wordList.insertBefore(newWordCard, wordList.firstChild);

            // 关闭模态框并重置表单
            const modal = bootstrap.Modal.getInstance(document.getElementById('addWordModal'));
            modal.hide();
            form.reset();

            // 显示成功提示
            showToast('添加成功！');
        }
    </script>
</body>
</html>